package com.foreveross.taskservice.core.domain.statitics.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;

import org.dayatang.domain.InstanceFactory;
import org.openkoala.koala.commons.domain.KoalaUUIDAbstractEntity;

import com.foreveross.taskservice.core.domain.statitics.StaticHistoryEntityRepository;
@javax.persistence.Table(name = "static_history_total")
@javax.persistence.Entity
public class StaticHistoryTotalEntity extends KoalaUUIDAbstractEntity{
	private static final long serialVersionUID = 1L;
	@javax.persistence.Id
	@javax.persistence.Column(name = "id", length = 32)
	@javax.persistence.GeneratedValue(generator = "system-uuid")
	@org.hibernate.annotations.GenericGenerator(name = "system-uuid", strategy = "uuid")
	private String id;
	/**
	 * 创建时间
	 */
	@Column(name ="create_time")
	private Date createTime;
	/**
	 * 抓取日期
	 */
	@Column(name ="grab_date")
	private String grabDate;
	/**
	 * 渠道ID
	 */
	@Column(name ="channel_id")
	private long channelId;
	/**
	 * 渠道编码
	 */
	@Column(name ="channel_code")
	private String channelCode;
	/**
	 * 渠道名称
	 */
	@Column(name ="channel_name")
	private String channelName;
	/**
	 * 任务总数
	 */
	@Column(name ="total")
	private Long totalNum;
	/**
	 * 任务抓取过程产生的流量大小合计
	 */
	@Column(name ="total_source_size")
	private Long totalSourceSize;
	/**
	 * 任务实际的抓取对象数量
	 */
	@Column(name ="total_count_num")
	private Long totalCountNum;
	/**
	 * 任务成功数
	 */
	@Column(name ="total_success_num")
	private Long totalSuccessNum;
	/**
	 * 任务正在执中数
	 */
	@Column(name ="doing")
	private Long doingNum;
	/**
	 * 任务等待中数
	 */
	@Column(name="waitting")
	private Long waittingNum;
	/**
	 * 任务暂停数
	 */
	@Column(name ="suspending")
	private Long suspendingNum = 0l;
	/**
	 * 任务抓取失败数
	 */
	@Column(name ="grab_failure_num")
	private Long grabFailureNum;
	/**
	 * 任务解析失败数
	 */
	@Column(name ="analysis_failure_num")
	private Long analysisFailureNum;
	/**
	 * 任务其它失败数
	 */
	@Column(name ="other_failure_num")
	private Long otherFailureNum;
	/**
	 * 业务上自定义的成功数
	 */
	@Column(name ="business_success_num")
	private Long businessSuccessNum = 0l;
	/**
	 * 业务上自定义的失败数
	 */
	@Column(name ="business_fail_num")
	private Long businessFailNum = 0l;

	
	
	private  static StaticHistoryEntityRepository getHistoryEntityRepository(){
		return InstanceFactory.getInstance(StaticHistoryEntityRepository.class);
	}
	
	public List<StaticHistoryTotalEntity> findVoByDate(String startDateStr,String endDateStr) {
		return getHistoryEntityRepository().findVoByDate(startDateStr,endDateStr);
	}
	
	public List<StaticHistoryTotalEntity> findVoByDate(String dateStr) {
		return getHistoryEntityRepository().findVoByDate(dateStr);
	}
	
	public void addEntity(List<StaticHistoryTotalEntity> entitys){
		for(StaticHistoryTotalEntity e : entitys){
			super.getRepository().save(e);
		}
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	public String getGrabDate() {
		return grabDate;
	}

	public void setGrabDate(String grabDate) {
		this.grabDate = grabDate;
	}

	public long getChannelId() {
		return channelId;
	}

	public void setChannelId(long channelId) {
		this.channelId = channelId;
	}

	public String getChannelName() {
		return channelName;
	}

	public void setChannelName(String channelName) {
		this.channelName = channelName;
	}
	
	public Long getTotalSourceSize() {
		return totalSourceSize;
	}

	public void setTotalSourceSize(Long totalSourceSize) {
		this.totalSourceSize = totalSourceSize;
	}

	public Long getTotalCountNum() {
		return totalCountNum;
	}

	public void setTotalCountNum(Long totalCountNum) {
		this.totalCountNum = totalCountNum;
	}

	public Long getTotalSuccessNum() {
		return totalSuccessNum;
	}

	public void setTotalSuccessNum(Long totalSuccessNum) {
		this.totalSuccessNum = totalSuccessNum;
	}

	public Long getGrabFailureNum() {
		return grabFailureNum;
	}

	public void setGrabFailureNum(Long grabFailureNum) {
		this.grabFailureNum = grabFailureNum;
	}

	public Long getAnalysisFailureNum() {
		return analysisFailureNum;
	}

	public void setAnalysisFailureNum(Long analysisFailureNum) {
		this.analysisFailureNum = analysisFailureNum;
	}

	public Long getOtherFailureNum() {
		return otherFailureNum;
	}

	public void setOtherFailureNum(Long otherFailureNum) {
		this.otherFailureNum = otherFailureNum;
	}


	public Long getSuspendingNum() {
		return suspendingNum;
	}

	public void setSuspendingNum(Long suspendingNum) {
		this.suspendingNum = suspendingNum;
	}

	public Long getDoingNum() {
		return doingNum;
	}

	public void setDoingNum(Long doingNum) {
		this.doingNum = doingNum;
	}

	public Long getWaittingNum() {
		return waittingNum;
	}

	public void setWaittingNum(Long waittingNum) {
		this.waittingNum = waittingNum;
	}

	public Long getTotalNum() {
		return totalNum;
	}

	public void setTotalNum(Long totalNum) {
		this.totalNum = totalNum;
	}

	public String getChannelCode() {
		return channelCode;
	}

	public void setChannelCode(String channelCode) {
		this.channelCode = channelCode;
	}

	public Long getBusinessSuccessNum() {
		return businessSuccessNum;
	}

	public void setBusinessSuccessNum(Long businessSuccessNum) {
		this.businessSuccessNum = businessSuccessNum;
	}

	public Long getBusinessFailNum() {
		return businessFailNum;
	}

	public void setBusinessFailNum(Long businessFailNum) {
		this.businessFailNum = businessFailNum;
	}

	@Override
	public String[] businessKeys() {
		return new String[] { getClass().getName() + id };
	}

	

}
